package me.acomma.groot.infrastructure;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class RestResult {
    private boolean success;

    private String code;

    private String message;

    private Object data;

    public RestResult() {

    }

    public RestResult(boolean success) {
        this.success = success;
    }

    public RestResult(boolean success, String code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public RestResult(boolean success, String code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static RestResult success() {
        return new RestResult(true, "200", "成功");
    }

    public static RestResult success(Object data) {
        return new RestResult(true, "200", "成功", data);
    }

    public static RestResult failure() {
        return new RestResult(false);
    }
}
